# ============================================================
# by howlink *
# Filename       : getOraUser.sh
#
# Description: get oracle user
# exmple: ./getOraUser orcl 
# =============================================================
#! /bin/bash

if [ $# -lt 1 ]; then
echo 'parameters is less 1'
   exit 1
fi

instid=$1

orauser=`cat /opt/howlink/lb-agent/application.properties | grep "^agent.oracle-user" | awk -F'=' '{ print $2 }' | sed 's/ //g'`
if [ -z "$orauser" ];then
    orauser=`ps -ef | grep ora_pmon | grep -v grep | head -n1 | sed -e 's/^[ \t]*//' | cut -d" " -f1`
fi
if [ "$orauser" = "" ];then
  echo ""
  exit 0
fi

gid=`cat /etc/passwd | grep "$orauser" | awk -F':' '{ print $3 }'`
if [ "$gid" = "" ];then
  echo ""
  exit 0
fi

group=`cat /etc/group | grep "$gid" | awk -F ':' '{ print $1 }'`

echo "$group"
